/*
 * Copyright (c) 2025 Li Auto Inc. and its affiliates
 * Licensed under the Apache License, Version 2.0(the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * Description: Core Configuration
 * AutoGenerate Code, DO NOT EDIT!!!
 * {{get_generation_time()}}
 * {{get_project_name()}}
 * {{get_vcos_version()}}
 */

/* Including File */
#include <nuttx/config.h>
#include "os_core.h"
#include "core_cfg.h"
#include "os_compiler_cfg.h"
#include "application_cfg.h"
#if defined(CONFIG_RT_FRAMEWORK_IPICALL) && (CONFIG_RT_FRAMEWORK_IPICALL == 1)
#include "os_ipicall.h"
#include "ipicall_cfg.h"
#endif

/* Local Macro Definition */

/* Local Enumeration Definition */

/* Local type & Structure Definition */

/* global Variable Definition */
{%- set core_config = get_core_configs() %}
{%- set hw2log = get_hw2log_map() %}
#define OS_START_SEC_CONST
#include "os_memmap.h"

/* Physical ID as index, Logical ID as Value */
CONST(uint32, OS_CONST) ulCoreIdTable[OS_CORE_PHYSICAL_CNT] = {
{%- for ele in hw2log: %}
    (uint32){{ele}},
{%- endfor %}
};

{%- set log2hw = get_log2hw_map() %}
/* Logical ID as index, Physical ID as Value */
CONST(uint32, OS_CONST) ulCoreIdLog2PhyTable[OS_CORE_CNT] = {
{%- for ele in log2hw: %}
    (uint32){{ele}},
{%- endfor %}
};

#define OS_STOP_SEC_CONST
#include "os_memmap.h"

{%- for core, core_val in core_config.items() %}
    {%- set core_num = core_val["core_id"][-1] %}
    {%- set bsw_app_name = get_bsw_app_from_coreid(core_num) %}

/*! Core{{core_num}} Configuration Implementation */
DeclareCore(OS_GLOBAL_VAR_NO_INIT_SECTION, {{core}}) = {
    /* .instance = */        &OSCOREOBJVAR({{core}}),
    /* .core_id  = */        {{core_val["core_id"]}},
    /* .PhyId  = */         (CoreIdType){{core_val["PhyId"]}},
#if defined(CONFIG_RT_FRAMEWORK_MULTIAPP) && (CONFIG_RT_FRAMEWORK_MULTIAPP== 1)
    /* .kernel_app = */      (os_app_cfg_t*)&OSAPPCFGVAR({{bsw_app_name}}),
    /* .app_ref  = */        os_core{{core_num}}_apps_cfg_ref_table,
    /* .app_count  = */      &os_core{{core_num}}_apps_cfg_ref_table_size,
#endif
#if defined(CONFIG_RT_FRAMEWORK_IPICALL) && (CONFIG_RT_FRAMEWORK_IPICALL == 1)
    /* .ipicall_refs = */     os_core{{core_num}}_ipicalls_cfg_ref_table,
    /* .ipicall_count = */    &os_core{{core_num}}_ipicalls_cfg_ref_table_size,
#endif /* CONFIG_RT_FRAMEWORK_IPICALL */
};
{%- endfor %}

DeclareOsRefTable(core, OS_CORE_CNT) = {
{%- for core in core_config.values() %}
    &OSCORECFGVAR(Os_Core{{core["core_id"][-1]}}),
{%-endfor%}
};

/* Local Variable Definition */

/* Local Function Declaration */

/* Local Function Implementation */

/* global Function Implementation */

